/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.github.ybq.parallaxviewpager;

import ohos.agp.components.Component;
import ohos.agp.components.ComponentContainer;
import ohos.agp.components.DirectionalLayout;
import ohos.agp.components.Image;
import ohos.agp.components.LayoutScatter;
import ohos.app.Context;


/**
 * The type Image directional layout.
 */
public class ImageDirectionalLayout extends DirectionalLayout {
    private Context mContext;
    private int resId;

    /**
     * Instantiates a new Image directional layout.
     *
     * @param context the context
     * @param resId   the res id
     */
    public ImageDirectionalLayout(Context context, int resId) {
        super(context);
        this.mContext = context;
        this.resId = resId;
        initView(resId);
    }


    private void initView(int id) {
        Component component = LayoutScatter.getInstance(mContext).parse(ResourceTable.Layout_layout_pageslider, this, true);
        setLayoutConfig(new ComponentContainer.LayoutConfig(ComponentContainer.LayoutConfig.MATCH_PARENT, ComponentContainer.LayoutConfig.MATCH_PARENT));
        Image image = (Image) component.findComponentById(ResourceTable.Id_img_pageslider);
        image.setImageAndDecodeBounds(id);
    }

}
